package com.cf.r1027_e;

import java.io.*;
import java.util.TreeMap;

public class d {

    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static StreamTokenizer in = new StreamTokenizer(br);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) throws IOException {
        in.nextToken(); int T = (int) in.nval;
        while (T-- > 0) {
            solve();
        }
        out.flush();
        out.close();
        br.close();
    }

    static void solve() throws IOException {
        in.nextToken(); int n = (int) in.nval;
        int[][] a = new int[n][2];
        for (int i = 0; i < n; i++) {
            in.nextToken(); a[i][0] = (int) in.nval;
            in.nextToken(); a[i][1] = (int) in.nval;
        }

        if (n == 1) {
            out.println(1);
            return;
        }

        long res = (long) 1e18 + 100;

        TreeMap<Integer, Integer> xs = new TreeMap<>();
        TreeMap<Integer, Integer> ys = new TreeMap<>();
        for (int[] t : a) {
            xs.put(t[0], xs.getOrDefault(t[0], 0) + 1);
            ys.put(t[1], ys.getOrDefault(t[1], 0) + 1);
        }

        res = Math.min(res, calcArea(xs, ys));

        for (int[] t : a) {
            remove(xs, t[0]);
            remove(ys, t[1]);

            long r1 = calcArea(xs, ys);
            if (r1 == n - 1) {
                r1 += Math.min(xs.lastKey() - xs.firstKey() + 1,
                        ys.lastKey() - ys.firstKey() + 1);
            }
            res = Math.min(res, r1);

            add(xs, t[0]);
            add(ys, t[1]);
        }

        out.println(res);
    }

    static void add(TreeMap<Integer, Integer> map, int key) {
        map.put(key, map.getOrDefault(key, 0) + 1);
    }

    static void remove(TreeMap<Integer, Integer> map, int key) {
        int cnt = map.get(key);
        if (cnt == 1) map.remove(key);
        else map.put(key, cnt - 1);
    }

    static long calcArea(TreeMap<Integer, Integer> xs, TreeMap<Integer, Integer> ys) {
        if (xs.isEmpty() || ys.isEmpty()) return Long.MAX_VALUE;
        long width = xs.lastKey() - xs.firstKey() + 1;
        long height = ys.lastKey() - ys.firstKey() + 1;
        return width * height;
    }
}
